#!/bin/csh -f

# arg: yyyymmdd
if ($#argv == 0) then
	echo "usage: batch_stk_backscatter 20090508"
	exit (0)
endif

if ( "$QUIGON_PATH" == "" ) then 
	setenv QUIGON_PATH "/home/user/somewhere"
endif

set start_t="$argv[1]"000000
set end_t="$argv[1]"235959

# Maybe we need to link the data first
# pushd ${QUIGON_PATH}/data
# rm -f *NP
# ln -s /somewhere/has/data/*NP ./
# popd

# and do the cleaning for the output dir
# pushd ${QUIGON_PATH}/output
# rm -f *
# popd

# now let quigon run
csh -f quigon.csh stk_backscatter $start_t $end_t 10.0

# prepare for the plot
source ${QUIGON_PATH}/scripts/plot/idl_setup.csh
#then change dir is not nececcary, but better keep this:
pushd ${QUIGON_PATH}/scripts/plot
idl << EOF
plotlidartxt, '../output/stk_${start_t}_${end_t}.backscat.txt', output_filename='../output/stk_${start_t}_${end_t}.backscat.ps', range=[-2, 1], /use_log, title='STK normalized lidar backscatter signal', colorbar_title='signal', elev_angle=75.0
EOF
popd

# and then mv the result to some safe place
# mv ${QUIGON_PATH}/output/*.png /somewhere/safe



